package org.ethan.pet.mapper;

import org.apache.ibatis.annotations.Param;
import org.ethan.basic.mapper.BaseMapper;
import org.ethan.pet.domain.Pet;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
@Repository
public interface PetMapper extends BaseMapper<Pet> {

    void onsale(Map<String, Object> params);

    void offSale(Map<String, Object> params);

    Pet loadByIdDetail(Long id);

    /**
     * update t_pet set ${timeField} = now(), state = #{state} where id in
     *         <foreach collection="ids" separator="," open="(" close=")" item="id">
     *             #{id}
     *         </foreach>
     * @param timeField 传入上架或者下架的时间
     * @param state 更改状态
     * @param ids 要更改的数据的id
     */
    void updateState(@Param("timeField") String timeField, @Param("state") Integer state, @Param("ids") List<Long> ids);

    /**
     * 根据id查询上架的宠物的详细信息
     * @param id
     * @param state
     * @return
     */
    Pet findByIdAndState(@Param("id") Long id, @Param("state") Integer state);


    List<Pet> batchSelectByIds(@Param("ids") List<Long> petIds, @Param("state") Integer state);
}
